{%include file="index.header.tpl.php"%}
{%include file="index.left.tpl.php"%}
  <!--主要内容开始-->
  <div class="content-wrapper">
    <section class="content">
      <div class="row">
        <section class="col-lg-12 connectedSortable">
         <div class="box box-default box-solid">
            <form name="myform" action="" method="post">
                <div class="box-header with-border">
                    <span class="fa fa-edit" style="float:left; font-size:18px; margin-top:2px; color:#3c8dbc;" ></span>
                    <p class="box-title">学科总课时批量设置</p>
                </div>
                <div class="box-body">
                       <div class="col-sm-5 form-group">
                              <label  class="col-sm-8 control-label text-right">
                                   学科：
                              </label>
                              <div class="input-group col-md-4 col-xs-12">
                                   <select class="form-control" name="subject_id">
									{%foreach from=$subject_lists key=key item=value%}
                                      <option value="{%$value.subject_id%}">{%$value.subject_name%}</option>
									{%/foreach%}
                                   </select>
                              </div> 
				       </div>
                        <div class="col-sm-7 form-group">
                              <label  class="col-sm-3 control-label" style="width:150px;">
                                   学科一周总课时：
                              </label>
                              <div class="input-group col-md-3 col-xs-12">
                                   <input type="text" class="form-control" name="week_hour" value="">
                              </div> 
				       </div>
                       <div style="clear:both;">
                           <ul id="treeDemo" class="ztree"></ul>
                           <div style="display:none;">
                                被勾选时：<input type="checkbox" id="py" class="checkbox first" checked /><span>关联父</span>
                                <input type="checkbox" id="sy" class="checkbox first" checked /><span>关联子</span><br/>
                                取消勾选时：<input type="checkbox" id="pn" class="checkbox first" checked /><span>关联父</span>
                                <input type="checkbox" id="sn" class="checkbox first" checked /><span>关联子</span><br/>
                            </div>
                        </div>
                </div>
            <!-- /.box-body -->
               <div class="box-footer text-center">
						<div id="hiddenBox"></div>
               		 <button type="submit" onclick="c();" class="btn btn-primary" > 确 定</button>
              </div>
             </form>
             </div><!--box box-default box-solid-->
        </section>   
           
        </div><!--row-->
    </section>
 </div>
  <!--主要内容结束-->
{%include file="index.footer.tpl.php"%}
<script type="text/javascript" src="static/js/jquery.ztree.core.js"></script><!--树形-->
<script type="text/javascript" src="static/js/jquery.ztree.excheck.js"></script><!--树形-->
<script type="text/javascript">
		var setting = {
			check: {
				enable: true,	
			},
			data: {
				simpleData: {
					enable: true
				}
			}
		};
		var zNodes =[
		{%foreach from=$class_lists key=key item=value%}
			{ id:"g{%$key%}", pId:0, name:"{%$value.grade_name%}", },
			{%foreach from=$value.class key=k item=v%}
			{ id:"c{%$v.class_id%}", pId:"g{%$key%}", name:"{%$v.class_name%}", open:true, last:true},
			{%/foreach%}
		{%/foreach%}
		];
		var code;
		
		function setCheck() {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			py = $("#py").attr("checked")? "p":"",
			sy = $("#sy").attr("checked")? "s":"",
			pn = $("#pn").attr("checked")? "p":"",
			sn = $("#sn").attr("checked")? "s":"",
			type = { "Y":py + sy, "N":pn + sn};
			zTree.setting.check.chkboxType = type;
			showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
		}
		function showCode(str) {
			if (!code) code = $("#code");
			code.empty();

			code.append("<li>"+str+"</li>");
		}
		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			setCheck();
			$("#py").bind("change", setCheck);
			$("#sy").bind("change", setCheck);
			$("#pn").bind("change", setCheck);
			$("#sn").bind("change", setCheck);
		});
		
		$(function(){
			     if ($( ).is(" ")) {
						$("this").attr("class","fudong");
                    }
			    
			})
function c()
{
	var delidID = "";
	var zTree = $.fn.zTree.getZTreeObj("treeDemo").getCheckedNodes(true);//获取所有选中状态的节点  
	for (var i = 0; i < zTree.length; i++) {  
		//delidID += zTree[i].id + ",";
		$("#hiddenBox").append('<input type="hidden" name="pid[]" value="'+zTree[i].id+'">');
	}

} 			
</script>
</body>
</html>

